<script lang="ts" setup>
import { useAppStore } from '@/store'

const { tabBarActive } = storeToRefs(useAppStore())
function switchTab(item, index: number) {
  tabBarActive.value = index
  switch (index) {
    case 0:
      uni.switchTab({
        url: '/pages/home/index',
      })
      break
    case 1:
      uni.switchTab({
        url: '/pages/my/index',
      })
      break
  }
}
</script>

<template>
  <div class="layout-default">
    <slot />
    <nut-tabbar
      v-model="tabBarActive"
      bottom
      safe-area-inset-bottom
      placeholder
      @tab-switch="switchTab"
    >
      <nut-tabbar-item tab-title="首页" icon="home" />
      <nut-tabbar-item tab-title="我的" icon="my" />
    </nut-tabbar>
  </div>
</template>

<style>
</style>
